﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace db_util {
	public class connection_string {

		private static string _ConnectionString;
		public static string ConnectionString {
			get {
				if (_ConnectionString != null)
					return _ConnectionString;
				return GetNewConnectionString();
			}
			set {
				_ConnectionString = value;
			}
		}

		public static string GetNewConnectionString() {
			string M_str_sqlcon;
			if (string.IsNullOrEmpty(_DB_Server) || string.IsNullOrEmpty(_DB_Name) || string.IsNullOrEmpty(_DB_Uid) || string.IsNullOrEmpty(_DB_Pwd)) {
#if DEBUG
				M_str_sqlcon = "server=192.168.0.113;user id=root;password=AaBbCc112233..;database=callcenter35;Charset=utf8;";
				//M_str_sqlcon = "server=61.162.59.62;user id=root;password=AaBbCc112233..;database=callcenter35;Charset=utf8;";
#else
				//M_str_sqlcon = "server=192.168.0.113;user id=root;password=AaBbCc112233..;database=callcenter35;Charset=utf8;";
				M_str_sqlcon = "server=61.162.59.62;user id=root;password=AaBbCc112233..;database=callcenter35;Charset=utf8;";
#endif
			} else
				M_str_sqlcon = $"server={_DB_Server};database={_DB_Name};user id={_DB_Uid};password={_DB_Pwd};Charset=utf8;";

			return M_str_sqlcon;
		}

		private static string _DB_Server;
		public static string DB_Server {
			set { _DB_Server = value; }
		}

		private static string _DB_Name;
		public static string DB_Name {
			set { _DB_Name = value; }
		}

		private static string _DB_Uid;
		public static string DB_Uid {
			set { _DB_Uid = value; }
		}

		private static string _DB_Pwd;
		public static string DB_Pwd {
			set { _DB_Pwd = value; }
		}
	}
}
